<?php

namespace Database\Seeders;

use App\Models\Category\Category;
use App\Models\Category\CategoryGroup;
use App\Models\SystemAdmin;
use Illuminate\Database\Seeder;

class ConfigCategorySeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $category_group = [
            [
                'title' => '配置分类',
                'name' => 'config',
                'depth' => '2',
            ],
            [
                'title' => '用户分组',
                'name' => 'user_group',
                'depth' => '1',
            ],
            [
                'title' => '商品分类',
                'name' => 'product',
                'depth' => '3',
            ],
            [
                'title' => '文章分类',
                'name' => 'article',
                'depth' => '1',
            ],
            [
                'title' => '话术分类',
                'name' => 'feedback',
                'depth' => '1',
            ],
            [
                'title' => '用户标签',
                'name' => 'labelgroup',
                'depth' => '1',
            ],
            [
                'title' => '附件分类',
                'name' => 'attachment',
                'depth' => '2',
            ]
        ];

        foreach ($category_group as $value){
            CategoryGroup::create($value);
        }


        $configs = [
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '1',
                'name' => implode('-',pinyin('基础配置',true)),
                'nickname' => '基础配置',
                'type' => 1,
                'sort' => '100',
                'children' => [
                    [
                        'top_id' => '1',
                        'pid' => '1',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '1,2',
                        'name' => 'wss-' . implode('-',pinyin('配置',true)),
                        'nickname' => 'wss配置',
                        'type' => 1,
                        'sort' => '0',
                    ],
                    [
                        'top_id' => '1',
                        'pid' => '1',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '1,3',
                        'name' => implode('-',pinyin('站点配置',true)),
                        'nickname' => '站点配置',
                        'type' => 1,
                        'sort' => '100',
                    ]
                ]
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '4',
                'name' => implode('-',pinyin('商城配置',true)),
                'nickname' => '商城配置',
                'type' => 1,
                'sort' => '90',
                'children' => [
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,5',
                        'name' => implode('-',pinyin('商城基础配置',true)),
                        'nickname' => '商城基础配置',
                        'type' => 1,
                        'sort' => '100',
                    ],
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,6',
                        'name' => implode('-',pinyin('付费会员配置',true)),
                        'nickname' => '付费会员配置',
                        'type' => 1,
                        'sort' => '90',
                    ],
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,7',
                        'name' => implode('-',pinyin('用户充值配置',true)),
                        'nickname' => '用户充值配置',
                        'type' => 1,
                        'sort' => '80',
                    ],
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,8',
                        'name' => implode('-',pinyin('用户等级配置',true)),
                        'nickname' => '用户等级配置',
                        'type' => 1,
                        'sort' => '70',
                    ],
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,9',
                        'name' => implode('-',pinyin('发票功能配置',true)),
                        'nickname' => '发票功能配置',
                        'type' => 1,
                        'sort' => '60',
                    ],
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,10',
                        'name' => implode('-',pinyin('售后退款配置',true)),
                        'nickname' => '售后退款配置',
                        'type' => 1,
                        'sort' => '50',
                    ],
                    [
                        'top_id' => '4',
                        'pid' => '4',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '4,11',
                        'name' => implode('-',pinyin('首页分享配置',true)),
                        'nickname' => '首页分享配置',
                        'type' => 1,
                        'sort' => '40',
                    ],
                ]
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '12',
                'name' => implode('-',pinyin('应用配置',true)),
                'nickname' => '应用端配置',
                'type' => 1,
                'sort' => '80',
                'children' => [
                    [
                        'top_id' => '12',
                        'pid' => '12',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '12,13',
                        'name' => implode('-',pinyin('公众号配置',true)),
                        'nickname' => '公众号配置',
                        'type' => 1,
                        'sort' => '100',
                    ],
                    [
                        'top_id' => '12',
                        'pid' => '12',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '12,14',
                        'name' => implode('-',pinyin('小程序配置',true)),
                        'nickname' => '小程序配置',
                        'type' => 1,
                        'sort' => '90',
                    ],
                    [
                        'top_id' => '12',
                        'pid' => '12',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '12,15',
                        'name' => implode('-',pinyin('客服端配置',true)),
                        'nickname' => '客服端配置',
                        'type' => 1,
                        'sort' => '80',
                    ],
                    [
                        'top_id' => '12',
                        'pid' => '12',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '12,16',
                        'name' => 'PC-' . implode('-',pinyin('站点配置',true)),
                        'nickname' => 'PC站点配置',
                        'type' => 1,
                        'sort' => '70',
                    ],
                    [
                        'top_id' => '12',
                        'pid' => '12',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '12,17',
                        'name' => 'APP-' . implode('-',pinyin('配置',true)),
                        'nickname' => 'APP配置',
                        'type' => 1,
                        'sort' => '60',
                    ],
                ]
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '18',
                'name' => implode('-',pinyin('支付配置',true)),
                'nickname' => '支付配置',
                'type' => 1,
                'sort' => '70',
                'children' => [
                    [
                        'top_id' => '18',
                        'pid' => '18',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '18,19',
                        'name' => implode('-',pinyin('微信支付配置',true)),
                        'nickname' => '微信支付配置',
                        'type' => 1,
                        'sort' => '100',
                    ],
                    [
                        'top_id' => '18',
                        'pid' => '18',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '18,20',
                        'name' => implode('-',pinyin('小程序支付配置',true)),
                        'nickname' => '小程序支付配置',
                        'type' => 1,
                        'sort' => '90',
                    ],
                    [
                        'top_id' => '18',
                        'pid' => '18',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '18,21',
                        'name' => implode('-',pinyin('线下支付配置',true)),
                        'nickname' => '线下支付配置',
                        'type' => 1,
                        'sort' => '80',
                    ],
                    [
                        'top_id' => '18',
                        'pid' => '18',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '18,22',
                        'name' => implode('-',pinyin('余额支付配置',true)),
                        'nickname' => '余额支付配置',
                        'type' => 1,
                        'sort' => '70',
                    ],
                    [
                        'top_id' => '18',
                        'pid' => '18',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '18,23',
                        'name' => implode('-',pinyin('支付宝支付配置',true)),
                        'nickname' => '支付宝支付配置',
                        'type' => 1,
                        'sort' => '60',
                    ],
                ]
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '24',
                'name' => implode('-',pinyin('分销配置',true)),
                'nickname' => '分销配置',
                'type' => 0,
                'sort' => '100',
                'children' => [
                    [
                        'top_id' => '24',
                        'pid' => '24',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '24,25',
                        'name' => implode('-',pinyin('分销模式',true)),
                        'nickname' => '分销模式',
                        'type' => 0,
                        'sort' => '100',
                    ],
                    [
                        'top_id' => '24',
                        'pid' => '24',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '24,26',
                        'name' => implode('-',pinyin('返佣设置',true)),
                        'nickname' => '返佣设置',
                        'type' => 0,
                        'sort' => '90',
                    ],
                    [
                        'top_id' => '24',
                        'pid' => '24',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '24,27',
                        'name' => implode('-',pinyin('提现设置',true)),
                        'nickname' => '提现设置',
                        'type' => 0,
                        'sort' => '80',
                    ],
                ]
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '28',
                'name' => implode('-',pinyin('积分配置',true)),
                'nickname' => '积分配置',
                'type' => 0,
                'sort' => '100',
                'children' => []
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '29',
                'name' => implode('-',pinyin('文件上传配置',true)),
                'nickname' => '文件上传配置',
                'type' => 1,
                'sort' => '100',
                'children' => [
                    [
                        'top_id' => '29',
                        'pid' => '29',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '29,30',
                        'name' => implode('-',pinyin('基础配置',true)),
                        'nickname' => '基础配置',
                        'type' => 1,
                        'sort' => '100',
                    ],
                    [
                        'top_id' => '29',
                        'pid' => '29',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '29,31',
                        'name' => implode('-',pinyin('阿里云配置',true)),
                        'nickname' => '阿里云配置',
                        'type' => 1,
                        'sort' => '90',
                    ],
                    [
                        'top_id' => '29',
                        'pid' => '29',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '29,32',
                        'name' => implode('-',pinyin('七牛云配置',true)),
                        'nickname' => '七牛云配置',
                        'type' => 1,
                        'sort' => '80',
                    ],
                    [
                        'top_id' => '29',
                        'pid' => '29',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '29,33',
                        'name' => implode('-',pinyin('腾讯云配置',true)),
                        'nickname' => '腾讯云配置',
                        'type' => 1,
                        'sort' => '70',
                    ],
                ]
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '34',
                'name' => 'system_sms',
                'nickname' => '短信配置',
                'type' => 0,
                'sort' => '100',
                'children' => []
            ],
            [
                'top_id' => '0',
                'pid' => '0',
                'category_group_id' => '1',
                'level' => '1',
                'path' => '35',
                'name' => implode('-',pinyin('第三方接口设置',true)),
                'nickname' => '第三方接口设置',
                'type' => 1,
                'sort' => '100',
                'children' => [
                    [
                        'top_id' => '35',
                        'pid' => '35',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '35,36',
                        'name' => implode('-',pinyin('短信配置',true)),
                        'nickname' => '短信配置',
                        'type' => 1,
                        'sort' => '100',
                    ],
                    [
                        'top_id' => '35',
                        'pid' => '35',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '35,37',
                        'name' => implode('-',pinyin('小票打印配置',true)),
                        'nickname' => '小票打印配置',
                        'type' => 1,
                        'sort' => '90',
                    ],
                    [
                        'top_id' => '35',
                        'pid' => '35',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '35,38',
                        'name' => implode('-',pinyin('采集商品配置',true)),
                        'nickname' => '采集商品配置',
                        'type' => 1,
                        'sort' => '80',
                    ],
                    [
                        'top_id' => '35',
                        'pid' => '35',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '35,39',
                        'name' => implode('-',pinyin('物流查询',true)),
                        'nickname' => '物流查询',
                        'type' => 1,
                        'sort' => '70',
                    ],
                    [
                        'top_id' => '35',
                        'pid' => '35',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '35,40',
                        'name' => implode('-',pinyin('电子面单',true)),
                        'nickname' => '电子面单',
                        'type' => 1,
                        'sort' => '60',
                    ],
                    [
                        'top_id' => '35',
                        'pid' => '35',
                        'category_group_id' => '1',
                        'level' => '2',
                        'path' => '35,41',
                        'name' => implode('-',pinyin('地图配置',true)),
                        'nickname' => '地图配置',
                        'type' => 1,
                        'sort' => '50',
                    ],
                ]
            ]
        ];

        foreach ($configs as $config){

            $childes = $config['children'];
            unset($config['children']);
            Category::create($config);

            foreach ($childes as $child){
                Category::create($child);
            }

        }
    }
}
